package com.example.deepai.controller;

import com.example.deepai.util.MilvusQueryUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/milvus")
@RequiredArgsConstructor
public class MilvusController {
    private final MilvusQueryUtil milvusQueryUtil;
    
    @GetMapping("/status")
    public Map<String, Object> checkStatus() {
        Map<String, Object> response = new HashMap<>();
        boolean isRunning = milvusQueryUtil.checkMilvusStatus();
        response.put("status", isRunning ? "running" : "not running");
        
        if (isRunning) {
            milvusQueryUtil.listCollections();
        }
        
        return response;
    }
}